﻿$(function () {
    var user,Type;
    if ($('#email').val() !== "" && $('#email').val()){
        user = $('#email').val();
    } else if (location.getQuery("user") !== "" && location.getQuery("user")){
        user = location.getQuery("user");
    }
    if (location.getQuery("Type") !== "" && location.getQuery("Type")) {
        Type = location.getQuery("Type");
    }
    //全选和全不选
    $("#table thead .all").click(function () {
        if ($(this).is(':checked')) {
            for (var i = 0; i < $("#tbody :checkbox").length; i++) {
                $("#tbody :checkbox")[i].checked = true;
            }
        } else {
            for (var i = 0; i < $("#tbody :checkbox").length; i++) {
                $("#tbody :checkbox")[i].checked = false
            }
        }
    });
    //点击侧边栏
    $("#sidebar .first").on("click", function () {
        if ($(this).attr("data-url")) {
            window.location.href = $(this).attr("data-url") + "?user=" + user + "&Type=" + Type;
        } else {
            if ($(this).hasClass("in")) {
                $(this).removeIn();
                $(this).next().slideUp("slow").removeClass("down");
                $(this).next().children().removeIn();
                $(this).find(".first-icon").removeClass("icon-angle-down");
            } else {
                $(".first").removeIn();
                $(this).in();
                $("#sidebar .secondbox").slideUp("slow").removeClass("down");
                $(this).next().slideDown("slow").addClass("down");
                $("#sidebar .first").find(".first-icon").removeClass("icon-angle-down");
                $(this).find(".first-icon").addClass("icon-angle-down");
            }
        }
    });
    //点击侧边栏二级导航
    $("#sidebar .secondbox>div").on("click", function () {
        window.location.href = $(this).attr("data-url") + "?user=" + user;
    });

    //手机菜单栏
    $("#menu").on("click", function () {
        $("#sidebar").slideToggle();
    });

    //搜索框
    $(".search-input").on("focus", function () {
        //$(".word-list").slideDown();
    });
    $(".search-input").on("blur", function () {
        //$(".word-list").slideUp();
    });

    
    
    //点击展开导航栏按钮
    $("#menu").on("click", function () {
        if ($(this).hasClass("in")) {
//          $("#main").css("padding-top", "120px");
            $(this).removeIn();
        } else {
            $("#main").css("padding-top", 0);
            $(this).in();
        }
        
    });
    $("li.dropdown").eq(1).on("click",function(){
    	logout();
    });

});


